package com.example.test.utils;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @author ：dengjue
 * @date ：Created in 2021/7/28 14:50
 * @description ：
 */
public class DateUtil {

    private static DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

    private static DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");

    /**
     * 获取当前时间
     * @return
     */
    public static String getTodayTime(){
        LocalDateTime localDateTime = LocalDateTime.now();
        return localDateTime.format(dateTimeFormatter);
    }

    /**
     * 获取当前日期
     * @return
     */
    public static String getToday(){
        LocalDate localDate = LocalDate.now();
        return localDate.format(dateFormatter);
    }
}
